home *** CD-ROM | disk | FTP | other *** search
/ Light ROM Gold / Light ROM Gold.iso / arexx / measure.lwm < prev    next >
Text File  |  1995-09-04  |  1KB  |  56 lines

  1. /* CMD:Measure */
  2. /*---------------------------
  3. Measure the distance between 2 selected points
  4. -------------------------------------------- */
  5. /* To use: Select 2 points. Run macro */
  6. /* Requires rexxmathlib.library */
  7. signal on error
  8. signal on syntax
  9. call addlib( "LWModelerARexx.port", 0 )
  10.  
  11. MATHLIB="rexxmathlib.library"
  12. IF POS(MATHLIB , SHOW('L')) = 0 THEN
  13.   IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
  14.     call notify(1,"!Can't find "MATHLIB)
  15.     exit
  16.     END
  17. totalpoints = xfrm_begin()
  18. call xfrm_end()
  19. call sel_mode( USER )
  20. n = xfrm_begin()
  21.  if n = 0  then do
  22.    call notify( 1, "!There are no points in this layer!" ) 
  23.    exit
  24.    end
  25. if n = 1 then do
  26.      call notify(1, "!You have only selected 1 point. Select 2 points.")
  27.       exit 
  28.       end 
  29. if n > 2 then do 
  30.      if n = totalpoints then do
  31.      call notify(1, "!You have either selected all or no points.  Please select 2.")
  32.      exit
  33.      end     
  34.      call notify(1, "!You have selected more than 2 points.  Try again!")        
  35.      exit
  36.      end
  37.  
  38. p = xfrm_getpos( 1 )
  39. q = xfrm_getpos(2)
  40. call xfrm_end()
  41.  
  42.  
  43. parse var p x1 y1 z1
  44. parse var q x2 y2 z2
  45. dx = x2 - x1
  46. dy = y2 - y1
  47. dz = z2 - z1
  48. distance = sqrt(dx**2 + dy**2 + dz**2)
  49. call notify(1,"!Distance ="||distance)
  50. exit
  51.  
  52. syntax:
  53. error:
  54.    call end_all()
  55.    call notify( 1, "!Rexx Script Error", "@"errortext( rc ), "Line "sigl )
  56.    exit